<?php
header("Content-Type=>text/html; charset=utf-8");
$act = isset($_GET['act']) ? $_GET['act'] : '' ;

$data = array();
switch ($act) {
    case 'getData':
       $data = '{
"code": 0,
"msg": "ok",
"data": {
"region": {
"region_id": "455",
"region_name": "百富国际大厦",
"first": 1
},
"menu": [
{
"menu_date": "12月07日",
"menu_week": "周三",
"token": "MDAwMDAwMDAwMIOtm5Y",
"order": [
"香辣龙虾饭套餐x1",
"鱼香肉丝五谷蒸面配爽口小藕片+五谷豆浆x1"
],
"menu_title": "已截止",
"goods": [
{
"goods_id": "37",
"goods_name": "枝竹豆腐焖比目鱼柳套餐（蔬菜会变化，如：菠菜、圆白菜、西兰花等）",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356c4672439.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "7",
"store_logo": "",
"store_slogan": "",
"goods_storage": 0,
"storage_activity": 0,
"sub": 100,
"discount": 0
},
{
"goods_id": "30",
"goods_name": "香辣龙虾饭套餐",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356cdbaa07a.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "9",
"store_logo": "",
"store_slogan": "",
"goods_storage": 0,
"storage_activity": 0,
"sub": 100,
"discount": 0
},
{
"goods_id": "44",
"goods_name": "笋干烧肉套餐（蔬菜会变化，如：鸡毛菜、圆白菜、杭白菜等）",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356bff82491.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "11",
"store_logo": "",
"store_slogan": "",
"goods_storage": 0,
"storage_activity": 0,
"sub": 100,
"discount": 0
}
],
"remind": {
"title": "当日已全部售罄",
"desc": "提前预定周四餐品享优惠"
}
},
{
"menu_date": "12月08日",
"menu_week": "周四",
"token": "MDAwMDAwMDAwMIOtm5U",
"order": [],
"menu_title": "",
"goods": [
{
"goods_id": "27",
"goods_name": "香辣卤肉饭套餐（听可乐or雪碧）",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356cf64d405.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "8",
"store_logo": "",
"store_slogan": "",
"goods_storage": 100,
"storage_activity": 1,
"sub": 0,
"discount": "0"
},
{
"goods_id": "3",
"goods_name": "元气牛腩饭套餐",
"goods_image": "http://wechat.baitime.cn/upload/image/20160921/57e22d3925adf.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "2",
"store_logo": "",
"store_slogan": "",
"goods_storage": 100,
"storage_activity": 1,
"sub": 0,
"discount": "0"
},
{
"goods_id": "13",
"goods_name": "黑猪肉外婆菜五谷蒸面配爽口小藕片+五谷豆浆",
"goods_image": "http://wechat.baitime.cn/upload/image/20160920/57e1252ee912b.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "4",
"store_logo": "",
"store_slogan": "",
"goods_storage": 100,
"storage_activity": 1,
"sub": 0,
"discount": "0"
}
],
"remind": {
"title": "距今日订餐结束",
"time": 1481162400,
"desc": "提前预定周五餐品享优惠"
}
},
{
"menu_date": "12月09日",
"menu_week": "周五",
"token": "MDAwMDAwMDAwMIOtm94",
"order": [],
"menu_title": "已售罄",
"goods": [
{
"goods_id": "30",
"goods_name": "香辣龙虾饭套餐",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356cdbaa07a.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "9",
"store_logo": "",
"store_slogan": "",
"goods_storage": 0,
"storage_activity": 1,
"sub": 100,
"discount": 0
},
{
"goods_id": "47",
"goods_name": "香菇滑鸡煲套餐",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356bce1a2ce.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "12",
"store_logo": "",
"store_slogan": "",
"goods_storage": 0,
"storage_activity": 1,
"sub": 100,
"discount": 0
},
{
"goods_id": "10",
"goods_name": "红焖羊排饭套餐",
"goods_image": "http://wechat.baitime.cn/upload/image/20160920/57e125b770374.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "3",
"store_logo": "",
"store_slogan": "",
"goods_storage": 0,
"storage_activity": 1,
"sub": 100,
"discount": 0
}
],
"remind": {
"title": "当日已全部售罄",
"desc": "提前预定周六餐品享优惠"
}
},
{
"menu_date": "12月10日",
"menu_week": "周六",
"token": "MDAwMDAwMDAwMIOtm90",
"order": [],
"goods": [
{
"goods_id": "3",
"goods_name": "元气牛腩饭套餐",
"goods_image": "http://wechat.baitime.cn/upload/image/20160921/57e22d3925adf.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "2",
"store_logo": "",
"store_slogan": "",
"goods_storage": 50,
"storage_activity": 1,
"sub": 0,
"discount": "0"
},
{
"goods_id": "13",
"goods_name": "黑猪肉外婆菜五谷蒸面配爽口小藕片+五谷豆浆",
"goods_image": "http://wechat.baitime.cn/upload/image/20160920/57e1252ee912b.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "4",
"store_logo": "",
"store_slogan": "",
"goods_storage": 50,
"storage_activity": 1,
"sub": 0,
"discount": "0"
},
{
"goods_id": "37",
"goods_name": "枝竹豆腐焖比目鱼柳套餐（蔬菜会变化，如：菠菜、圆白菜、西兰花等）",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356c4672439.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "7",
"store_logo": "",
"store_slogan": "",
"goods_storage": 50,
"storage_activity": 1,
"sub": 0,
"discount": "0"
}
],
"remind": []
},
{
"menu_date": "12月11日",
"menu_week": "周日",
"menu_title": "休息"
}
]
}
}';
        $data = json_decode($data, true);

        break;
    case 'getNowData':
        // 获取当天菜单及信息

        // 需要提交参数（POST提交）：
        // region_id  = 455
        // menu_date  = 12月04日
        if ($_POST['menu_date'] == '12月07日'){
            $data = '{
"code": 0,
"msg": "ok",
"data": {
"region": {
"region_id": "455",
"region_name": "百富国际大厦",
"first": 1
},
"menu": 
{
"menu_date": "12月07日",
"menu_week": "周三",
"token": "MDAwMDAwMDAwMIOtm5Y",
"order": [
"香辣龙虾饭套餐x1",
"鱼香肉丝五谷蒸面配爽口小藕片+五谷豆浆x1"
],
"menu_title": "已截止",
"goods": [
{
"goods_id": "37",
"goods_name": "枝竹豆腐焖比目鱼柳套餐（蔬菜会变化，如：菠菜、圆白菜、西兰花等）",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356c4672439.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "7",
"store_logo": "",
"store_slogan": "",
"goods_storage": 0,
"storage_activity": 0,
"sub": 100,
"discount": 0
},
{
"goods_id": "30",
"goods_name": "香辣龙虾饭套餐",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356cdbaa07a.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "9",
"store_logo": "",
"store_slogan": "",
"goods_storage": 0,
"storage_activity": 0,
"sub": 100,
"discount": 0
},
{
"goods_id": "44",
"goods_name": "笋干烧肉套餐（蔬菜会变化，如：鸡毛菜、圆白菜、杭白菜等）",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356bff82491.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "11",
"store_logo": "",
"store_slogan": "",
"goods_storage": 0,
"storage_activity": 0,
"sub": 100,
"discount": 0
}
],
"remind": {
"title": "当日已全部售罄",
"desc": "提前预定周四餐品享优惠"
}
}
}
}';
        }

        if ($_POST['menu_date'] == '12月08日'){
            $data = '{
"code": 0,
"msg": "ok",
"data": {
"region": {
"region_id": "455",
"region_name": "百富国际大厦",
"first": 1
},
"menu": 
{
"menu_date": "12月08日",
"menu_week": "周四",
"token": "MDAwMDAwMDAwMIOtm5U",
"order": [],
"menu_title": "",
"goods": [
{
"goods_id": "27",
"goods_name": "香辣卤肉饭套餐（听可乐or雪碧）",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356cf64d405.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "8",
"store_logo": "",
"store_slogan": "",
"goods_storage": 100,
"storage_activity": 1,
"sub": 0,
"discount": "0"
},
{
"goods_id": "3",
"goods_name": "元气牛腩饭套餐",
"goods_image": "http://wechat.baitime.cn/upload/image/20160921/57e22d3925adf.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "2",
"store_logo": "",
"store_slogan": "",
"goods_storage": 100,
"storage_activity": 1,
"sub": 0,
"discount": "0"
},
{
"goods_id": "13",
"goods_name": "黑猪肉外婆菜五谷蒸面配爽口小藕片+五谷豆浆",
"goods_image": "http://wechat.baitime.cn/upload/image/20160920/57e1252ee912b.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "4",
"store_logo": "",
"store_slogan": "",
"goods_storage": 100,
"storage_activity": 1,
"sub": 0,
"discount": "0"
}
],
"remind": {
"title": "距今日订餐结束",
"time": 1481162400,
"desc": "提前预定周五餐品享优惠"
}
}
}
}';
        }

        if ($_POST['menu_date'] == '12月09日'){
            $data = '{
"code": 0,
"msg": "ok",
"data": {
"region": {
"region_id": "455",
"region_name": "百富国际大厦",
"first": 1
},
"menu": 
{
"menu_date": "12月09日",
"menu_week": "周五",
"token": "MDAwMDAwMDAwMIOtm94",
"order": [],
"menu_title": "已售罄",
"goods": [
{
"goods_id": "30",
"goods_name": "香辣龙虾饭套餐",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356cdbaa07a.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "9",
"store_logo": "",
"store_slogan": "",
"goods_storage": 0,
"storage_activity": 1,
"sub": 100,
"discount": 0
},
{
"goods_id": "47",
"goods_name": "香菇滑鸡煲套餐",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356bce1a2ce.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "12",
"store_logo": "",
"store_slogan": "",
"goods_storage": 0,
"storage_activity": 1,
"sub": 100,
"discount": 0
},
{
"goods_id": "10",
"goods_name": "红焖羊排饭套餐",
"goods_image": "http://wechat.baitime.cn/upload/image/20160920/57e125b770374.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "3",
"store_logo": "",
"store_slogan": "",
"goods_storage": 0,
"storage_activity": 1,
"sub": 100,
"discount": 0
}
],
"remind": {
"title": "当日已全部售罄",
"desc": "提前预定周六餐品享优惠"
}
}
}
}';
        }
        if ($_POST['menu_date'] == '12月10日'){
            $data = '{
"code": 0,
"msg": "ok",
"data": {
"region": {
"region_id": "455",
"region_name": "百富国际大厦",
"first": 1
},
"menu": 
{
"menu_date": "12月10日",
"menu_week": "周六",
"token": "MDAwMDAwMDAwMIOtm90",
"order": [],
"goods": [
{
"goods_id": "3",
"goods_name": "元气牛腩饭套餐",
"goods_image": "http://wechat.baitime.cn/upload/image/20160921/57e22d3925adf.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "2",
"store_logo": "",
"store_slogan": "",
"goods_storage": 50,
"storage_activity": 1,
"sub": 0,
"discount": "0"
},
{
"goods_id": "13",
"goods_name": "黑猪肉外婆菜五谷蒸面配爽口小藕片+五谷豆浆",
"goods_image": "http://wechat.baitime.cn/upload/image/20160920/57e1252ee912b.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "4",
"store_logo": "",
"store_slogan": "",
"goods_storage": 50,
"storage_activity": 1,
"sub": 0,
"discount": "0"
},
{
"goods_id": "37",
"goods_name": "枝竹豆腐焖比目鱼柳套餐（蔬菜会变化，如：菠菜、圆白菜、西兰花等）",
"goods_image": "http://wechat.baitime.cn/upload/image/20161123/58356c4672439.jpg",
"goods_combo": "",
"market_price": "35",
"shop_price": "25",
"store_id": "7",
"store_logo": "",
"store_slogan": "",
"goods_storage": 50,
"storage_activity": 1,
"sub": 0,
"discount": "0"
}
],
"remind": []
}
}
}';
        }

        if ($_POST['menu_date'] == '12月11日'){
            $data = '{
"code": 0,
"msg": "ok",
"data": {
"region": {
"region_id": "455",
"region_name": "百富国际大厦",
"first": 1
},
"menu": 
{
"menu_date": "12月11日",
"menu_week": "周日",
"menu_title": "休息"
}
}
}';
        }
        $data = json_decode($data, true);
        break;
    case 'getGoodsDetal':
        //获取菜品详情

        //参数 POST提交
        // goods_id = 44

        $data = [
            "code" => 0,
            "msg" => "ok",
            "data" => [
                //id，名称，套餐包含，图片，富文本详情
                "goods_id" => "37",
                "goods_name" => "枝竹豆腐焖比目鱼柳套餐（蔬菜会变化，如：菠菜、圆白菜、西兰花等）",
                "goods_combo" => "虾-鱼-水",
                "goods_image" => "http://wechat.baitime.cn/upload/image/20161123/58356c4672439.jpg",
                "goods_content" => '1111',
            ]
        ];
        break;
    case 'submitCart':
        //提交购物车

        // 参数 POST提交
        /*
        cart = '{
            "region": {
                "region_id": 455,
                "region_name": "百富国际大厦"
            },
            "data": [
                {
                    "menu_date": "12月05日",
                    "menu_week": "周一",
                    "token": "MDAwMDAwMDAwMIOtm5Y",
                    "goods": [
                        {
                            "goods_id": 37,
                            "goods_num": 2
                        },
                        {
                            "goods_id": 44,
                            "goods_num": 1
                        }
                    ]
                },
                {
                    "menu_date": "12月04日",
                    "menu_week": "周二",
                    "token": "MDAwMDAwMDAwMIOtm94",
                    "goods": [
                        {
                            "goods_id": 30,
                            "goods_num": 1
                        }
                    ]
                },
            ]
        }'

        $goods1[] = ['goods_id' => 37, 'goods_num' => 2];
        $goods1[] = ['goods_id' => 44, 'goods_num' => 1];
        $goods2[] = ['goods_id' => 30, 'goods_num' => 1];
        $cartList = [
            'region' => [ 'region_id' => 455, 'region_name' => '百富国际大厦' ],
            'data' => [
                ['menu_date' => '12月05日', 'menu_week' => '周一', 'token' => "MDAwMDAwMDAwMIOtm5Y" ,'goods' => $goods1 ],
                ['menu_date' => '12月04日', 'menu_week' => '周二', 'token' => "MDAwMDAwMDAwMIOtm94", 'goods' => $goods2 ],
            ]
        ];
        echo json_encode($cartList);
 */
        $data = json_decode('{
"code": 0,
"msg": "ok",
"data": {
"region_id": 455,
"region_name": "百富国际大厦",
"coupon_id": 0,
"coupon_sn": 0,
"coupon_value": 0,
"menu": [
{
"menu_week": "周一",
"menu_date": "12月05日",
"goods": [
{
"goods_id": "37",
"goods_name": "枝竹豆腐焖比目鱼柳套餐（蔬菜会变化，如：菠菜、圆白菜、西兰花等）",
"goods_num": 2,
"market_price": "35",
"shop_price": "25",
"discount_price": "9"
},
{
"goods_id": "44",
"goods_name": "笋干烧肉套餐（蔬菜会变化，如：鸡毛菜、圆白菜、杭白菜等）",
"goods_num": 1,
"market_price": "35",
"shop_price": "25",
"discount_price": "3"
}
],
"goods_price": 75
},
{
"menu_week": "周二",
"menu_date": "12月06日",
"goods": [
{
"goods_id": "30",
"goods_name": "香辣龙虾饭套餐",
"goods_num": 1,
"market_price": "35",
"shop_price": "25",
"discount_price": "0"
}
],
"goods_price": 25
}
],
"goods_amount": 100,
"discount_amount": 12,
"order_amount": 88,
"deliver_time": "每天送餐时间11:30-12:20"
}
}', true);
        break;
    case 'submitOrder':
        //立即下单 提交订单

        // 参数 POST提交
        /*
        region_id = 455;   //楼ID
        region_name = 楼宇名称;
        member_name = 联系人
        member_phone = 联系方式
        address = 详细地址
         */

        $data['code'] = 0;
        $data['msg'] = 'ok';
        $data['data'] = [ "url" => "http://xxxx"];
        //支付完成 code = 0 则跳转URL， 否则 code != 0 提示msg
        break;
    default :

        echo '1：<a href="http://t.baitime.cn/wechat/shop/getData">http://t.baitime.cn/wechat/shop/getData（进入页面获取所有）</a>' . '<br>';
        echo '            <a href="http://t.baitime.cn/getData.json">getData（参数详细说明 新）</a>' . '<br>';
        echo '2：<a href="http://t.baitime.cn/wechat/shop/getCurrentData">http://t.baitime.cn/wechat/shop/getNowData（获取指定天的数据，变更楼宇也要触发）</a>' . '<br>';
        echo '<br>==================================================<br>';
        echo 'POST提交方式 提交参数1 ： region_id 参数2： menu_date   列如：region_id=455  menu_date=12月21日';
        echo '<br>';
        echo '3：<a href="http://t.baitime.cn/wechat/shop/getGoodsDetail">http://t.baitime.cn/wechat/shop/getGoodsDetail（菜品详情）</a>' . '<br>';
        echo '<br>==================================================<br>';
        echo 'GET提交方式 提交参数 ： goods_id = 11';
        echo '<br>';
        echo '4：<a href="http://t.baitime.cn/wechat/shop/submitCart">http://t.baitime.cn/wechat/shop/submitCart（提交购物车）</a>' . '<br>';
        echo '<br>==================================================<br>';
        echo '提交的参数：POST cart = [
            {
                "menu_date": "12月05日",
                "menu_week": "周一",
                "token": "MDAwMDAwMDAwMIOtm5Y",
                "goods": [
                    {
                        "goods_id": 37,
                        "goods_num": 2
                    },
                    {
                        "goods_id": 44,
                        "goods_num": 1
                    }
                ]
            },
            {
                "menu_date": "12月04日",
                "menu_week": "周二",
                "token": "MDAwMDAwMDAwMIOtm5U",
                "goods": [
                    {
                        "goods_id": 30,
                        "goods_num": 1
                    }
                ]
            }
        ]';
        echo '<br>==================================================<br>';
        echo '5：<a href="http://t.baitime.cn/wechat/shop/submitOrder">http://t.baitime.cn/wechat/shop/submitOrder（立即下单 提交订单）</a>' . '<br>';
        echo '6：<a href="http://t.baitime.cn/wechat/shop/getRegionList">http://t.baitime.cn/wechat/shop/getRegionList（楼宇列表）</a>' . '<br>';
        echo '<br>==================================================<br>';
        echo 'GET提交方式 提交参数1 ： keyword = XX楼';
        echo '<br>';
        break;
}
 // json_encode($data);  $data 数组转成json
echo json_encode($data);





/*
$str = '[
            {
                "menu_date": "12月05日",
                "goods": [
                    {
                        "goods_id": 37,
                        "goods_num": 2
                    },
                    {
                        "goods_id": 44,
                        "goods_num": 1
                    }
                ]
            },
            {
                "menu_date": "12月04日",
                "goods": [
                    {
                        "goods_id": 30,
                        "goods_num": 1
                    }
                ]
            }
        ]';
json_encode($str, true);
// JSON 转成 数组
*/
exit;